package com.song.controller;

import com.aliyuncs.exceptions.ClientException;
import com.song.pojo.Result;
import com.song.utils.AliyunOSSOperator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@RestController
@RequestMapping("/upload")
@Slf4j
public class UploadFileController {
    @Autowired
    private AliyunOSSOperator aliyunOSSOperator;
    @PostMapping
    public Result uploadFile(MultipartFile  file) throws IOException, ClientException {
        log.info("上传文件：{}",file.getOriginalFilename());
        String url = aliyunOSSOperator.uploadFile(file);
        return Result.success(url);
    }
}
